package com.example.operation.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.operation.domin.SysDispatch;
import com.example.operation.dto.SysDispatchDto;
import com.example.operation.mapper.SysDispatchMapper;
import com.example.operation.service.SysDispatchService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDateTime;

@Service
public class SysDispatchServiceImpl extends ServiceImpl<SysDispatchMapper, SysDispatch> implements SysDispatchService {

    @Autowired
    private SysDispatchMapper sDM;

    @Transactional(rollbackFor = Exception.class)
    @Override
    public void save(SysDispatchDto sysDispatchDto) {
        SysDispatch sysDispatch = new SysDispatch();
 /*       LambdaQueryWrapper<SysDispatch> lambda = new QueryWrapper<SysDispatch>().lambda()
                .eq(SysDispatch::getStartOrderTime,sysDispatchDto.getStartOrderTime());*/
        BeanUtils.copyProperties(sysDispatchDto,sysDispatch);
        sysDispatch.setStartOrderTime(LocalDateTime.now());
        sysDispatch.setEndOrderTime(LocalDateTime.now());
        sDM.insert(sysDispatch);
    }
}
